package com.lzmpt.imchat.adapter;

import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lzmpt.imchat.R;


import java.util.List;

import androidx.recyclerview.widget.RecyclerView;


public class MainFuctionAdapter extends RecyclerView.Adapter<MainFuctionAdapter.ViewHolder> {
    private Context mContext;
    private List<String> datas;
    private int[] res = new int[]{
            R.drawable.image_fuction_one
            , R.drawable.image_fuction_two,
            R.drawable.image_fuction_three,
            R.drawable.image_fuction_four,
            R.drawable.image_fuction_five,
            R.drawable.image_fuction_six,
            R.drawable.image_fuction_seven,
            R.drawable.image_fuction_eight,
            R.drawable.image_fuction_nine,
            R.drawable.image_fuction_ten};


    public interface MainFuctionListener {
        void onMainFuctionClick(View view, int position);
    }

    public MainFuctionAdapter(Context context, List<String> datas) {
        mContext = context;
        this.datas = datas;


    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_main_fuction, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {

        holder.tvName.setText(datas.get(position));
        holder.ivHead.setImageResource(res[position]);
    }

    @Override
    public int getItemCount() {
        return datas == null ? 0 : datas.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView ivHead;
        private TextView tvName;


        public ViewHolder(final View itemView) {
            super(itemView);
            ivHead = (ImageView) itemView.findViewById(R.id.iv_head);
            tvName = (TextView) itemView.findViewById(R.id.tv_name);

        }

    }
}
